package com.hare.system_server.controller;


import com.hare.common.result.R;
import com.hare.common.utils.PageUtils;
import com.hare.system_api.dto.SysDictDTO;
import com.hare.system_api.vo.SysDictDataVO;
import com.hare.system_server.serice.SysDictDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: Hare
 * @description: 字典数据相关Api
 * @author: Hare
 * @create: 2022-12-01 10:38
 * @Version 6.0.1
 **/
@RestController
@RequestMapping("/dictData")
public class SysDictDataController {

    @Autowired
    SysDictDataService sysDictDataService;


    /**
     * 根据名称，类型，状态查询字典数据信息(分页)
     *
     * @param dict 字典信息
     * @return
     */
    @PostMapping("/pageDictData")
    public R<PageUtils<SysDictDataVO>> pageDictDataInfo(@RequestBody SysDictDTO dict) {
        return R.success(sysDictDataService.pageDictDataInfo(dict));
    }

    /**
     * 根据字典数据ID查询信息
     *
     * @param dictCode 字典数据ID
     * @return
     */
    @GetMapping(value = "/{dictCode}")
    public R<List<SysDictDataVO>> getInfo(@PathVariable String dictCode) {
        return R.success(sysDictDataService.selectDictDataById(dictCode));
    }
}
